package com.lhg.tcp;

import java.io.InputStream;
import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.net.Socket;
import java.time.LocalDateTime;

public class ServeSocketTest {
    public static void main(String[] args) throws Exception {
        // 创建ServerSocket
        ServerSocket server = new ServerSocket();
        // 绑定在某一个端口上
        server.bind(new InetSocketAddress(8080));
        while (true){
            // 监听在这个端口
            Socket socket = server.accept();
            System.out.println("ssss");
            String hostAddress = socket.getInetAddress().getHostAddress();
            LocalDateTime now = LocalDateTime.now();
            System.out.println("有客户端连接"+hostAddress+"NOW:"+now);
            new ServeThread(socket).start();
        }

    }

}
